<template>
  <div class="order-submission">
    <div
      class="allAddress"
      :style="store_self_mention ? '' : 'padding-top: 0rem'"
    >
      <!-- <div class="nav acea-row">
        <div
          class="item font-color-red"
          :class="shipping_type === 0 ? 'on' : 'on2'"
          @click="addressType(0)"
          v-if="store_self_mention"
        ></div>
        <div
          class="item font-color-red"
          :class="shipping_type === 1 ? 'on' : 'on2'"
          @click="addressType(1)"
          v-if="store_self_mention"
        ></div>
      </div> -->
      <div
        class="address acea-row row-between-wrapper"
        v-if="shipping_type === 0"
        @click="goAddressPages"
        :style="{ height: onlyVirtual ? '1.6rem' : '2.32rem' }"
      >
        <div v-if="!onlyVirtual">
          <div class="addressCon" v-if="addressInfo.real_name">
            <div class="province">
              {{ addressInfo.province }} {{ addressInfo.city }}
              {{ addressInfo.district }}
            </div>
            <div class="detail">
              {{ addressInfo.detail }}
            </div>
            <div class="name">
              {{ addressInfo.real_name }}
              <span class="phone">{{
                addressInfo.phone.substr(0, 3) +
                  "****" +
                  addressInfo.phone.substr(7)
              }}</span>
            </div>
          </div>
          <div class="addressCon" v-else>
            <div class="setaddress">设置收货地址</div>
          </div>
        </div>
        <div class="phone_info" v-else>
          <div class="addressCon" v-if="Object.keys(phoneInfo).length == 0">
            请填写手机号
          </div>
          <div class="addressCon" v-else>
            <div class="name">
              <p class="phone">手机号</p>
              <span class="phone">{{
                phoneInfo.phone.substr(0, 3) +
                  "****" +
                  phoneInfo.phone.substr(7)
              }}</span>
            </div>
          </div>
        </div>
        <div class="imgDiv">
          <img src="@assets/images/to-shop.png" alt="" />
        </div>
        <!-- <div class="iconfont icon-jiantou"></div> -->
      </div>
      <div
        class="address acea-row row-between-wrapper"
        v-else
        @click="showStoreList"
      >
        <div class="addressCon">
          <div class="name" v-if="storeItem">
            {{ storeItem.name }}
            <span class="phone" v-text="storeItem.phone"></span>
          </div>
          <div
            v-text="storeItem.address + ',' + storeItem.detailed_address"
            v-if="storeItem && storeItem.address && storeItem.detailed_address"
          ></div>
        </div>
        <div class="iconfont icon-jiantou"></div>
      </div>
      <div class="line">
        <img src="@assets/images/line.png" />
      </div>
    </div>
    <div class="payWay">
      <span class="pay-title">支付方式</span>
      <span class="pay-way">在线支付</span>
    </div>
    <OrderGoods
      :evaluate="0"
      :cartInfo="orderGroupInfo.cartInfo"
      :type="2"
    ></OrderGoods>
    <div class="wrapper">
      <div
        class="item acea-row row-between-wrapper"
        @click="couponTap"
        v-if="deduction === false"
      >
        <div>优惠劵</div>
        <div
          class="discount"
          :style="{
            color: usableCoupon.coupon_price ? '#FF3C39' : 'rgba(0, 0, 0, 0.4)'
          }"
        >
          {{
            usableCoupon.coupon_price
              ? `-￥${usableCoupon.coupon_price}.00`
              : "请选择"
          }}
          <span
            class="iconfont icon-jiantou"
            :style="{
              color: usableCoupon.coupon_price
                ? '#FF3C39'
                : 'rgba(0, 0, 0, 0.2)'
            }"
          ></span>
        </div>
      </div>
      <!-- <div class="item acea-row row-between-wrapper" v-if="deduction === false">
        <div>积分抵扣</div>
        <div class="discount">
          <div class="select-btn">
            <div class="checkbox-wrapper">
              <label class="well-check">
                <input type="checkbox" v-model="useIntegral" />
                <i class="icon"></i>
                <span class="integral">
                  当前积分
                  <span class="num font-color-red">
                    {{ userInfo.integral || 0 }}
                  </span>
                </span>
              </label>
            </div>
          </div>
        </div>
      </div> -->

      <!-- <div
        class="item acea-row row-between-wrapper"
        v-if="
          orderGroupInfo.priceGroup.vipPrice > 0 &&
            userInfo.vip &&
            pinkId == 0 &&
            orderGroupInfo.bargain_id == 0 &&
            orderGroupInfo.combination_id == 0 &&
            orderGroupInfo.seckill_id == 0
        "
      >
        会员优惠
        <div class="discount">-￥{{ orderGroupInfo.priceGroup.vipPrice }}</div>
      </div> -->
      <div
        class="item acea-row row-between-wrapper"
        v-if="shipping_type === 0 && !onlyVirtual"
      >
        <div>配送方式</div>
        <div class="pu">普通配送</div>
        <div class="discount">
          {{
            orderPrice.pay_postage > 0
              ? "￥" + orderPrice.pay_postage
              : "免运费"
          }}
        </div>
      </div>
      <div class="item acea-row row-between-wrapper" v-if="shipping_type === 0">
        <div>首单立减</div>
        <!-- <div class="pu">首单立减</div> -->
        <div class="discount">
          {{ "￥" + orderGroupInfo.priceGroup.firstReducePrice }}
        </div>
      </div>
      <div
        style="padding:0.27rem 0; display:none;"
        class="item acea-row row-between-wrapper"
        v-if="shipping_type === 0"
      >
        <div
          style="padding:0 0.3rem;width:100%;display:flex;position:relative;"
          @click="showInvoice"
        >
          <div>开具发票</div>
          <div
            class="pu"
            style="color:rgba(0, 0, 0, 0.7);"
            v-show="alltrue == 0"
          >
            点击填写发票信息
          </div>
          <div
            class="pu"
            style="color:rgba(0, 0, 0, 0.7);"
            v-show="alltrue == 1"
          >
            本次开具发票
          </div>
          <div
            class="discount"
            style="position:absolute;top:50%;right:0.3rem;transform:translate(0,-50%);"
          >
            <img
              class="toShopImg"
              :class="{ jiantou: is_showinv == true }"
              src="@assets/images/to-shop.png"
              alt=""
              style="float:left;"
            />
          </div>
        </div>
        <div class="invoice" v-show="is_showinv">
          <div class="list">
            <div class="tipTitle">发票详情</div>
            <div class="item acea-row row-between-wrapper">
              <div>发票类型</div>
              <div class="input">
                <span>电子发票</span>
              </div>
            </div>
            <div class="item acea-row row-between-wrapper">
              <div>抬头类型</div>
              <div class="input selectItem" style="">
                <span
                  @click="changetype"
                  class="setPositon"
                  style="display:inline-flex;align-items:center;"
                >
                  <img
                    v-show="personType == 1"
                    class="selectImg setMargin"
                    src="../../assets/images/checked.png"
                    alt=""
                  />
                  <img
                    v-show="personType == 2"
                    class="selectImg setMargin"
                    src="../../assets/images/unchecked.png"
                    alt=""
                  />
                  个人
                </span>
                <span
                  @click="changetype1"
                  class="setPositon"
                  style="margin-left:1.24rem;display:inline-flex;align-items:center;"
                >
                  <img
                    v-show="personType == 1"
                    class="selectImg setMargin"
                    src="../../assets/images/unchecked.png"
                    alt=""
                  />
                  <img
                    v-show="personType == 2"
                    class="selectImg setMargin"
                    src="../../assets/images/checked.png"
                    alt=""
                  />
                  企业
                </span>
              </div>
            </div>
            <div
              class="item acea-row row-between-wrapper"
              v-show="personType == 2"
            >
              <div>发票抬头</div>
              <div class="input">
                <input
                  @blur="reginvoiceRise"
                  type="text"
                  v-model="invoiceRise"
                  class="id"
                  :class="{ showred: showred1 == 1 }"
                  placeholder="抬头名称"
                />
              </div>
            </div>
            <div
              class="item acea-row row-between-wrapper"
              v-show="personType == 2"
            >
              <div>发票税号</div>
              <div class="input">
                <input
                  @blur="reginvoiceNumber"
                  type="text"
                  v-model="invoiceNumber"
                  class="id"
                  :class="{ showred: showred2 == 1 }"
                  placeholder="纳税人识别号"
                />
              </div>
            </div>
          </div>
          <div class="list">
            <div class="tipTitle">收票人信息</div>
            <div
              class="item acea-row row-between-wrapper"
              v-show="personType == 1"
            >
              <div>收票人信息<span class="mastFall">*</span></div>
              <div class="input" style="padding-left: 0.3rem">
                <span>{{ addressInfo.real_name }}</span>
              </div>
            </div>
            <div class="item acea-row row-between-wrapper">
              <div>收票人手机<span class="mastFall">*</span></div>
              <div class="input" style="padding-left: 0.3rem">
                <span>{{ addressInfo.phone | hide }}</span>
              </div>
            </div>
            <div class="item acea-row row-between-wrapper">
              <div>收票人邮箱<span class="mastFall">*</span></div>
              <div class="input" style="padding-left: 0.3rem">
                <input
                  @blur="regemail"
                  type="text"
                  v-model="email"
                  class="id"
                  :class="{ showred: showred3 == 1 }"
                  placeholder="用来接收电子发票邮件"
                />
              </div>
            </div>
          </div>
          <div class="list">
            <div class="tipTitle">
              发票内容<span class="titleDetail" style="margin-left:0.1rem;"
                >发票内容选项已根据税法调整，具体以展示为准</span
              >
            </div>
            <div class="item acea-row row-between-wrapper">
              <div>商品明细</div>
              <div class="input" style="text-align:right;">
                <img
                  v-show="invoiceType == 2"
                  @click="invoiceType = 1"
                  class="selectImg selectImg1"
                  src="../../assets/images/unchecked.png"
                  alt=""
                />
                <img
                  v-show="invoiceType == 1"
                  class="selectImg selectImg1"
                  src="../../assets/images/checked.png"
                  alt=""
                />
              </div>
            </div>
            <div class="item acea-row row-between-wrapper">
              <div>商品类别</div>
              <div class="input" style="text-align:right;">
                <img
                  v-show="invoiceType == 1"
                  @click="invoiceType = 2"
                  class="selectImg selectImg1"
                  src="../../assets/images/unchecked.png"
                  alt=""
                />
                <img
                  v-show="invoiceType == 2"
                  class="selectImg selectImg1"
                  src="../../assets/images/checked.png"
                  alt=""
                />
              </div>
            </div>
            <div v-show="invoiceType == 2" class="tipTitle titleDetail">
              发票内容将本单商品所属类别（电器电子产品及配件）及价格信息，发票金额为实际支付金额。
            </div>
            <div v-show="invoiceType == 1" class="tipTitle titleDetail">
              发票内容将显示详细商品名称与价格信息，发票金额为实际支付金额。
            </div>
          </div>
          <!-- <div class="modifyBnt" @click="submit">确定</div> -->
        </div>
      </div>
      <!-- <div v-else>
        <div class="item acea-row row-between-wrapper">
          <div>联系人</div>
          <div class="discount">
            <input
              type="text"
              placeholder="请填写您的联系姓名"
              v-model="contacts"
            />
          </div>
        </div>
        <div class="item acea-row row-between-wrapper">
          <div>联系电话</div>
          <div class="discount">
            <input
              type="text"
              placeholder="请填写您的联系电话"
              v-model="contactsTel"
            />
          </div>
        </div>
      </div> -->
      <div class="item row-between-wrapper flexDiv">
        <div>备注信息</div>
        <textarea
          ref="textareaHeight"
          style="background:none;"
          placeholder="选填，请先和商家协商一致"
          v-model="mark"
        ></textarea>
      </div>
    </div>
    <!-- <div class="wrapper">
      <div class="item">
        <div>支付方式</div>
        <div class="list">
          <div
            class="payItem acea-row row-middle"
            :class="active === 'weixin' ? 'on' : ''"
            @click="payItem('weixin')"
            v-show="isWeixin"
          >
            <div class="name acea-row row-center-wrapper">
              <div
                class="iconfont icon-weixin2"
                :class="active === 'weixin' ? 'bounceIn' : ''"
              ></div>
              微信支付
            </div>
            <div class="tip">微信快捷支付</div>
          </div>
          <div
            class="payItem acea-row row-middle"
            :class="active === 'weixin' ? 'on' : ''"
            @click="payItem('weixin')"
            v-show="!isWeixin"
          >
            <div class="name acea-row row-center-wrapper">
              <div
                class="iconfont icon-weixin2"
                :class="active === 'weixin' ? 'bounceIn' : ''"
              ></div>
              微信支付
            </div>
            <div class="tip">微信快捷支付</div>
          </div>
          <div
            class="payItem acea-row row-middle"
            :class="active === 'yue' ? 'on' : ''"
            @click="payItem('yue')"
          >
            <div class="name acea-row row-center-wrapper">
              <div
                class="iconfont icon-icon-test"
                :class="active === 'yue' ? 'bounceIn' : ''"
              ></div>
              余额支付
            </div>
            <div class="tip">可用余额：{{ userInfo.now_money || 0 }}</div>
          </div>
          <div
            class="payItem acea-row row-middle"
            :class="active === 'offline' ? 'on' : ''"
            @click="payItem('offline')"
            v-if="
              offlinePayStatus === 1 &&
                deduction === false &&
                shipping_type === 0
            "
          >
            <div class="name acea-row row-center-wrapper">
              <div
                class="iconfont icon-yinhangqia"
                :class="active === 'offline' ? 'bounceIn' : ''"
              ></div>
              线下支付
            </div>
            <div class="tip">线下方便支付</div>
          </div>
        </div>
      </div>
    </div> -->
    <div class="show_price">
      <p class="goods_total">
        <span>商品总计</span>
        <span>￥{{ orderPrice.total_price }}</span>
      </p>
      <p class="coupon_total" v-if="Number(orderPrice.total_reduce) != 0">
        <span>优惠合计</span>
        <span>-￥{{ orderPrice.total_reduce }}</span>
      </p>
    </div>
    <div class="alertDiv" v-show="toPayMoney" @click="hidetoPayMoney">
      <div class="payType" @click.stop="nothing()">
        <div class="title">
          <span @click="hidetoPayMoney()">取消</span>
          确认付款
        </div>
        <div
          class="oneChoice"
          @click="choiceType('aliPay')"
          v-show="this.zfbShow == '0'"
        >
          <img class="iconPic" src="@assets/images/alipay_icon.png" alt="" />
          <div class="right right1">
            <span>支付宝支付</span>
            <img
              class="choice"
              v-if="active == 'aliPay'"
              src="@assets/images/choice.png"
              alt=""
            />
            <img
              class="choice"
              v-if="active == 'weChatPay'"
              src="@assets/images/choice1.png"
              alt=""
            />
          </div>
        </div>
        <div class="oneChoice" @click="choiceType('weChatPay')">
          <img class="iconPic" src="@assets/images/wechatpay_icon.png" alt="" />
          <div class="right">
            <span>微信支付</span>
            <img
              class="choice"
              v-if="active == 'aliPay'"
              src="@assets/images/choice1.png"
              alt=""
            />
            <img
              class="choice"
              v-if="active == 'weChatPay'"
              src="@assets/images/choice.png"
              alt=""
            />
          </div>
        </div>
        <div class="payMoney" @click="createOrder">立即付款</div>
      </div>
    </div>

    <!-- <div class="moneyList">
      <div
        class="item acea-row row-between-wrapper numAndPrice"
        v-if="orderPrice.total_price !== undefined"
      >
        <div class="goodsNum">共{{ orderNum }}件</div>
        <div class="money">
          小计:<span class="small">￥</span
          ><span class="red">{{ orderPrice.total_price }}</span>
        </div>
      </div>
      <div
        class="item acea-row row-between-wrapper"
        v-if="orderPrice.pay_postage > 0"
      >
        <div>运费：</div>
        <div class="money">+￥{{ orderPrice.pay_postage }}</div>
      </div>
      <div
        class="item acea-row row-between-wrapper"
        v-if="orderPrice.coupon_price > 0"
      >
        <div>优惠券抵扣：</div>
        <div class="money">-￥{{ orderPrice.coupon_price }}</div>
      </div>
      <div
        class="item acea-row row-between-wrapper"
        v-if="orderPrice.deduction_price > 0"
      >
        <div>积分抵扣：</div>
        <div class="money">-￥{{ orderPrice.deduction_price }}</div>
      </div>
    </div> -->

    <div style="height:1.2rem"></div>
    <div class="footer acea-row row-between-wrapper numAndPrice">
      <div
        class="goodsNum"
        style="font-size:0.24rem;font-weight:400;color:rgba(0,0,0,.3);"
      >
        共计{{ orderNum }}件,
      </div>
      <div class="money money1" style="color:black;font-weight:500;">
        合计:<span
          class="small"
          style="font-size:0.28rem;font-weight:600;color:#FC404A;;"
          >￥</span
        ><span
          class="red"
          style="font-size:0.28rem;font-weight:bold;color:#FC404A;"
        >
          <!-- {{ orderPrice.total_price }} -->
          <font style="font-size:0.4rem;">{{ firstprice }}</font>
          <font style="font-size:0.24rem;">{{
            `${secondprice ? "." : ""}${secondprice}`
          }}</font>
        </span>
      </div>
      <div class="settlement" @click="showAllDiv()" style="background:#FC404A">
        提交订单
      </div>
    </div>
    <CouponListWindow
      v-on:couponchange="changecoupon($event)"
      v-model="showCoupon"
      :price="orderPrice.total_price"
      :checked="usableCoupon.id"
      :cartid="cartid"
      @checked="changeCoupon"
      :order_key="orderGroupInfo.orderKey"
    ></CouponListWindow>
    <AddressWindow
      @checked="changeAddress"
      @redirect="addressRedirect"
      v-model="showAddress"
      :checked="addressInfo.id"
      ref="mychild"
    ></AddressWindow>
  </div>
</template>
<style scoped>
.order-submission .wrapper .item .carnum {
  height: 0.44rem;
  position: absolute;
  right: 0.3rem;
}
.order-submission .wrapper .item .carnum div {
  width: 0.4rem;
  text-align: center;
  height: 100%;
  line-height: 0.4rem;
  font-size: 0.32rem;
  color: #a4a4a4;
}
.order-submission .wrapper .item .carnum .reduce {
  border-right: 0;
  border-radius: 0.03rem 0 0 0.03rem;
}
.order-submission .wrapper .item .carnum .reduce.on {
  border-color: #e3e3e3;
  color: #dedede;
  margin-right: 0.02rem;
}
.order-submission .wrapper .item .carnum .plus {
  border-left: 0;
  border-radius: 0 0.03rem 0.03rem 0;
  background: rgba(245, 245, 245, 1);
}
.order-submission .wrapper .item .carnum .num {
  color: #282828;
  background: rgba(245, 245, 245, 1);
  width: 0.88rem;
  margin-right: 0.02rem;
}
.shoppingCart .invalidGoods {
  background-color: #fff;
}
.flexDiv {
  display: flex;
  justify-content: space-between;
}
.flexDiv textarea {
  flex: 1;
}
.numAndPrice {
  justify-content: flex-end;
}
.numAndPrice .goodsNum {
  padding-right: 0.14rem;
  color: rgba(0, 0, 0, 1);
  font-size: 0.28rem;
  line-height: 0.4rem;
}
.numAndPrice .money {
  font-size: 0.28rem;
  color: rgba(0, 0, 0, 1);
  line-height: 0.4rem;
}
.numAndPrice .money1 {
  margin-right: 0.4rem;
}
.numAndPrice .money .small,
.numAndPrice .money .red {
  color: rgba(255, 50, 62, 1);
  font-size: 0.28rem;
  line-height: 0.4rem;
}
.numAndPrice .money .small {
  font-size: 0.2rem;
}
.order-submission .wrapper .shipping select {
  color: #999;
  padding-right: 0.15rem;
}
.order-submission .wrapper .shipping .iconfont {
  font-size: 0.3rem;
  color: #515151;
}
.order-submission .allAddress {
  width: 100%;
  /* background-image: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  background-image: -webkit-linear-gradient(
    to bottom,
    #e93323 0%,
    #f5f5f5 100%
  );
  background-image: -moz-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%); */
}
.order-submission .allAddress .nav {
  width: 7.1rem;
  margin: 0 auto;
}
.order-submission .allAddress .nav .item {
  width: 3.55rem;
}
.order-submission .allAddress .nav .item.on {
  position: relative;
  width: 2.5rem;
}
.order-submission .allAddress .nav .item.on:before {
  position: absolute;
  bottom: 0;
  content: "快递配送";
  font-size: 0.28rem;
  display: block;
  height: 0;
  width: 3.55rem;
  border-width: 0 0.2rem 0.8rem 0;
  border-style: none solid solid;
  border-color: transparent transparent #fff;
  z-index: 9;
  border-radius: 0.07rem 0.3rem 0 0;
  text-align: center;
  line-height: 0.8rem;
}
.order-submission .allAddress .nav .item:nth-of-type(2).on:before {
  content: "到店自提";
  border-width: 0 0 0.8rem 0.2rem;
  border-radius: 0.3rem 0.07rem 0 0;
}
.order-submission .allAddress .nav .item.on2 {
  position: relative;
}
.order-submission .allAddress .nav .item.on2:before {
  position: absolute;
  bottom: 0;
  content: "到店自提";
  font-size: 0.28rem;
  display: block;
  height: 0;
  width: 4.6rem;
  border-width: 0 0 0.6rem 0.6rem;
  border-style: none solid solid;
  border-color: transparent transparent #f7c1bd;
  border-radius: 0.4rem 0.06rem 0 0;
  text-align: center;
  line-height: 0.6rem;
}
.order-submission .allAddress .nav .item:nth-of-type(1).on2:before {
  content: "快递配送";
  border-width: 0 0.6rem 0.6rem 0;
  border-radius: 0.06rem 0.4rem 0 0;
}
.order-submission .allAddress .address {
  width: 7.5rem;
  height: 2.32rem;
  margin: 0 auto;
}
.order-submission .allAddress .address .imgDiv {
  position: absolute;
  right: 0.3rem;
  top: 0.38rem;
  width: 0.28rem;
}
.order-submission .allAddress .address .imgDiv img {
  width: 100%;
}
.order-submission .allAddress .line {
  width: 7.5rem;
  margin: 0 auto;
}
.order-submission .wrapper .item .discount input::placeholder {
  color: #ccc;
}
.payWay {
  width: 100%;
  height: 0.88rem;
  margin: 0.12rem 0;
  background: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.payWay .pay-title {
  font-size: 0.28rem;
  color: rgba(0, 0, 0, 0.9);
  padding-left: 0.3rem;
  font-weight: 500;
}
.payWay .pay-way {
  font-size: 0.28rem;
  color: rgba(0, 0, 0, 0.6);
  padding-right: 0.3rem;
}
.alertDiv {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.payType {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: auto;
  background: #fff;
  z-index: 3;
}
.payType .title {
  width: 100%;
  text-align: center;
  line-height: 0.44rem;
  font-size: 0.32rem;
  color: rgba(0, 0, 0, 1);
  padding: 0.34rem 0 0.18rem 0;
  text-align: center;
  border-bottom: 0.02rem solid rgba(0, 0, 0, 0.1);
}
.payType .title span {
  position: absolute;
  top: 0.36rem;
  left: 0.32rem;
  color: rgba(0, 0, 0, 0.5);
  font-size: 0.28rem;
}
.payType .oneChoice {
  padding: 0 0 0 0.3rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.payType .oneChoice .right {
  flex: 1;
  justify-content: space-between;
  align-items: center;
  display: flex;
  line-height: 0.4rem;
  padding: 0.4rem 0.3rem 0.4rem 0;
}
.payType .oneChoice .right1 {
  border-bottom: 0.02rem solid rgba(0, 0, 0, 0.1);
}
.payType .oneChoice .iconPic {
  margin: 0.3rem 0.3rem 0.3rem 0;
  width: 0.6rem;
  height: 0.6rem;
}
.payType .oneChoice span {
  flex: 1;
}
.payType .oneChoice .choice {
  width: 0.28rem;
  height: 0.28rem;
}
.payType .payMoney {
  font-size: 0.3rem;
  line-height: 1;
  color: #fff;
  line-height: 1;
  padding: 0.29rem 2.88rem;
  margin: 0.32rem 0.14rem;
  background-color: rgba(255, 50, 62, 1);
  border-radius: 0.16rem;
}
.jiantou {
  transform: rotate(90deg);
}
</style>
<style scoped>
.invoice {
  width: 100%;
}
.tipTitle {
  width: 100%;
  /* background: rgba(244, 244, 244, 1); */
  padding: 0.2rem 0.3rem;
  padding-left: 0;
  font-size: 12px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.4);
}
.titleDetail {
  font-size: 0.2rem;
  font-family: PingFangSC-Regular, PingFang SC;
  color: rgba(0, 0, 0, 0.2);
}
.invoice .wrapper {
  background-color: #fff;
  padding: 0.34rem 0 0 0.3rem;
  width: 100%;
  height: 1.74rem;
}

.invoice .wrapper .wrapList {
  /* margin:0.34rem 0 0 0.3rem; */
}
.invoice .wrapper .wrapList .item {
  border-radius: 0.2rem;
  position: relative;
}
.invoice .wrapper .wrapList .item .picTxt {
  /* width:4.45rem; */
}
.invoice .wrapper .wrapList .item .picTxt .pictrue {
  width: 1.1rem;
  height: 1.1rem;
  position: relative;
}
.invoice .wrapper .wrapList .item .picTxt .pictrue img {
  width: 100%;
  height: 100%;
  border-radius: 0.16rem;
}
/* .invoice .wrapper .wrapList .item .picTxt .pictrue .alter{
  width:0.3rem;
  height:0.3rem;
  border-radius:50%;
  position:absolute;
  bottom:0;
  right:0;
  } */
.invoice .wrapper .wrapList .item .picTxt .text {
  /* width:3.25rem; */
  font-size: 0.28rem;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  margin-left: 0.2rem;
}
.invoice .wrapper .wrapList .item .picTxt .text .name {
  /* width:100%;
  font-size:0.3rem;
  color:#282828; */
  margin-bottom: 0.12rem;
}
.invoice .wrapper .wrapList .item .picTxt .text span {
  /* font-size:0.24rem; */
  /* color:#999;
  margin-top:0.1rem; */
  margin-left: 0.22rem;
}
.picTxt .text span.setRed {
  font-size: 0.24rem;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(252, 64, 74, 1);
}
.mastFall {
  color: rgba(252, 64, 74, 1);
}
.invoice .wrapper .wrapList .item .bnt {
  font-size: 0.24rem;
  background-color: #fff;
  border-radius: 0.27rem;
  width: 1.4rem;
  height: 0.54rem;
  border: 0.02rem solid #e93323;
}
.invoice .wrapper .wrapList .item .currentBnt {
  position: absolute;
  right: 0;
  top: 0;
  font-size: 0.26rem;
  background-color: rgba(233, 51, 35, 0.1);
  width: 1.4rem;
  height: 0.48rem;
  border-radius: 0 0.2rem 0 0.2rem;
}
.invoice .list {
  background-color: #fff;
  border-bottom: 1px solid #f2f2f2;
  padding: 0 0.3rem;
}
.invoice .list:first-child {
  border-top: 1px solid #f2f2f2;
}
.invoice .list .item {
  /* padding: 0.2rem 0 0.2rem 0; */
  padding: 0.2rem 0;
  /* border-bottom: 1px solid #f2f2f2; */
  /* margin-left: 0.3rem; */
  font-size: 0.28rem;
  color: #282828;
  display: flex;
}
.invoice .list .item .pictrue {
  width: 0.88rem;
  height: 0.88rem;
}
.invoice .list .item .pictrue img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.invoice .list .item .input {
  /* width: 4.15rem; */
  text-align: left;
  color: rgba(0, 0, 0, 0.7);
  flex: 1;
  padding-left: 0.6rem;
}
.invoice .list .item .input input {
  color: rgba(0, 0, 0, 0.6);
  text-align: left;
  width: 100%;
}
.invoice .list .item .input input::-webkit-input-placeholder {
  color: rgba(0, 0, 0, 0.3);
}
.invoice .list .item .input .id {
  width: 3.65rem;
}
.invoice .list .item .input .iconfont {
  font-size: 0.35rem;
  /* margin:1.28rem */
}
.invoice .list .item .input .iconfont.icon-xiangyou {
  font-size: 0.3rem;
  margin-left: 0.27rem;
}
.invoice .modifyBnt {
  position: fixed;
  bottom: 0;
  font-size: 0.3rem;
  color: #fff;
  width: 100%;
  /* height:0.9rem; */
  /* border-radius:0.5rem; */
  text-align: center;
  line-height: 1rem;
  /* margin:0.76rem auto 0 auto; */
  height: 1rem;
  background: rgba(255, 50, 62, 1);
}
.invoice .logOut {
  font-size: 0.32rem;
  text-align: center;
  width: 6.9rem;
  height: 0.9rem;
  border-radius: 0.45rem;
  margin: 0.3rem auto 0.7rem auto;
}
.invoice .selectImg {
  width: 0.32rem;
  height: 0.32rem;
  /* float: left; */
}
.invoice .selectImg1 {
  float: right;
}
.invoice .setPositon {
  position: relative;
  /* padding-left: 0.5rem; */
}
.invoice .setMargin {
  /* position: absolute;
  top: 50%;
  transform: translate(0, -50%);
  left: 0; */
  margin-right: 0.2rem;
  /* margin-top: 0.04rem; */
  /* margin-right: 0.18rem; */
}

.showred::-webkit-input-placeholder {
  color: rgba(252, 64, 74, 1) !important;
}
/* 订单总价和优惠价格展示 */
.show_price {
  width: 100%;
  margin-top: 0.4rem;
  margin-bottom: 0.32rem;
}
.show_price p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.3rem;
  box-sizing: border-box;
  font-size: 0.28rem;
  font-weight: 400;
}
.show_price p:first-child {
  margin-bottom: 0.24rem;
}
.show_price p span:first-child {
  color: #000000;
}
.show_price p span:last-child {
  color: #ff3c39;
}
/* 虚拟商品收货信息 */
.phone_info {
  width: 100%;
  height: 100%;
  padding-top: 0.38rem;
  box-sizing: border-box;
}
.phone_info .phone:last-child {
  display: inline-block;
  font-size: 0.28rem;
  font-weight: bold;
  color: rgba(0, 0, 0, 0.7);
  line-height: 0.4rem;
  margin-top: 0.12rem;
}
</style>
<script>
import OrderGoods from "@components/OrderGoods";
import CouponListWindow from "@components/CouponListWindow";
import AddressWindow from "@components/AddressWindow";

import {
  postOrderConfirm,
  postOrderComputed,
  createOrder,
  getOpenId
} from "@api/order";
import { storeListApi } from "@api/store";
import { getWechatConfig } from "@api/store";
// import wx from "weixin-js-sdk";
import shareMsg from "../../assets/js/common/shareConfig.js";
import { getUser } from "@api/user";
import { pay } from "@libs/wechat";
import { isWeixin } from "@utils";
import { mapGetters } from "vuex";
import cookie from "@utils/store/cookie";
import { setTimeout } from "timers";
const NAME = "OrderSubmission",
  _isWeixin = isWeixin();
const LONGITUDE = "user_longitude";
const LATITUDE = "user_latitude";
export default {
  name: NAME,
  components: {
    OrderGoods,
    CouponListWindow,
    AddressWindow
  },
  props: {},
  computed: {
    ...mapGetters(["storeItems"]),
    storeItem: function() {
      if (JSON.stringify(this.storeItems) == "{}") {
        return this.storeList;
      } else {
        return this.storeItems;
      }
    }
  },
  data: function() {
    return {
      onlyVirtual: false, // 是否有虚拟商品
      phoneInfo: {}, // 虚拟商品手机信息
      zfbShow: "",
      cartid: "",
      offlinePayStatus: 2,
      from: _isWeixin ? "weChatPayH5" : "weChatPayPage",
      deduction: true,
      isWeixin: _isWeixin,
      pinkId: 0,
      active: _isWeixin ? "weChatPay" : "aliPay",
      showCoupon: false,
      showAddress: false,
      addressInfo: {},
      couponId: 0,
      orderGroupInfo: {
        priceGroup: {
          firstReducePrice: "0.00"
        }
      },
      usableCoupon: {},
      addressLoaded: false,
      useIntegral: false,
      orderPrice: {
        pay_price: "计算中"
      },
      mark: "",
      system_store: {},
      shipping_type: 0,
      contacts: "",
      contactsTel: "",
      store_self_mention: 0,
      userInfo: {},
      storeList: {},
      toPayMoney: false,
      // invoiceType:'',
      // personType:'',
      // email:'',
      // invoiceNumber:'',
      // invoiceRise:'',
      from1: "h5",
      orderId: "",
      is_inv: "",
      orderNum: 0,

      //发票信息
      id: "",
      firstprice: "",
      secondprice: "",
      showred1: 0,
      showred2: 0,
      showred3: 0,
      //商品缩略图
      image: "",
      //订单金额
      price: "",
      //收票人信息
      name: "",
      //收票人手机
      mobilePhone: "",
      //发票回传信息
      invoiceRise: "", //发票抬头
      invoiceNumber: "", //发票税号
      email: "", //邮箱

      //抬头类型 1个人 2企业
      personType: 1,
      //发票内容类型 1商品明细 2商品类别
      invoiceType: 1,
      //是否显示发票
      is_showinv: false,
      //发票全部校验是否通过
      alltrue: 0,
      reg1: /^[\u4e00-\u9fa5]{2,20}$/, //发票抬头
      reg2: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/ //邮箱
    };
  },
  watch: {
    useIntegral() {
      this.computedPrice();
    },
    $route(n) {
      if (n.name === NAME) {
        console.log("qweqwe");
        // this.getUserInfo();
        // this.getCartInfo();
        var that = this;
      }
    },
    shipping_type() {
      this.computedPrice();
    }
  },
  updated() {
    this.$nextTick(() => {
      this.componentDidMount();
    });
  },
  mounted: function() {
    // wx.miniProgram.navigateTo({url: '/pages/webview/webview?webURL=http://channels.h5.cbct.cn/downloadPage', });
    this.componentDidMount();
    // document.body.style.height = window.screen.availHeight +'px';
    // window.addEventListener('resize', () => {
    //     if (document.activeElement.tagName == 'INPUT') {
    //         alert('123');
    //         //延迟出现是因为有些 Android 手机键盘出现的比较慢
    //         window.setTimeout(() => {
    //             document.activeElement.scrollIntoViewIfNeeded();
    //         }, 100);
    //     }
    // });
    // let isFromApp = this.$route.query.from1;
    // if (isFromApp == undefined) {
    //   isFromApp = "h5";
    // }
    // this.from1 = isFromApp;
    document.body.addEventListener("touchstart", () => {
      const u = navigator.userAgent;
      const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端
      // alert('android'+isAndroid)
      if (isAndroid && this.from1 != "app") {
        // android统一处理，不影响ios的自身处理
        const body = document.getElementsByTagName("body")[0]; // 兼容获取body
        const regDom = document.querySelector(".order-submission"); // 获取页面根元素
        const content = document.querySelector(".order-submission"); // 表单内容部分
        // const scrollHeight = body.scrollHeight // 网页文档高
        // const scrollTop = body.scrollTop// 卷上去的高
        const clientHeight = body.clientHeight; //可见高
        const fixHeight = clientHeight / 3; // 定位高，弹出键盘时input距浏览器上部的距离，自己定义合适的
        // 符合需弹出键盘的元素query
        const queryStr =
          'input[type="text"], input[type="tel"], input[type="password"], textarea';
        const inputs = content.querySelectorAll(queryStr);
        // console.log(inputs)
        regDom.style.top = 0;
      }
    });
    let u = navigator.userAgent,
      app = navigator.appVersion;
    // let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
    let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    let top1;
    let isReset;
    if (isIOS) {
      document.body.addEventListener("focusin", () => {
        //软键盘弹出的事件处理
        isReset = false;
        setTimeout(() => {
          top1 = Math.max(
            window.pageYOffset,
            document.documentElement.scrollTop,
            document.body.scrollTop,
            document.scrollingElement.scrollTop
          );
          // window.scroll(0, top1);
        }, 300);
      });

      window.addEventListener("focusout", function() {
        isReset = true;
        setTimeout(() => {
          //当焦点在弹出层的输入框之间切换时先不归位
          if (isReset) window.scroll(0, top1); //失焦后强制让页面保留在原来的位置
        }, 200);
      });
    }
    let that = this;
    const from1 = "from1";
    if (cookie.get(from1)) {
      this.from1 = cookie.get(from1);
    }
    if (this.from1 == "app" || this.from1.indexOf("3Dapp") != "-1") {
      shareMsg.shareConfig("app", "0", "0", "", "", "", "", "", "0");
      this.$nextTick(() => {
        setTimeout(() => {
          this.getParameter();
          window["onWebResponse"] = str => {
            that.onWebResponse(str);
          };
        }, 0);
      });
      this.zfbShow = "0";
    } else {
      this.zfbShow = "1";
      this.active = "weChatPay";
    }
    that.getUserInfo();
    that.getCartInfo();
    that.getList();

    if (that.$route.query.pinkid !== undefined)
      that.pinkId = that.$route.query.pinkid;
    if (that.$route.params.id !== undefined)
      that.cartid = that.$route.params.id;
    // if (that.$route.query.invoiceRise !== undefined)
    //   that.invoiceRise = that.$route.query.invoiceRise;
    // if (that.$route.query.invoiceNumber !== undefined)
    //   that.invoiceNumber = that.$route.query.invoiceNumber;
    // if (that.$route.query.email !== undefined)
    //   that.email = that.$route.query.email;
    // if (that.$route.query.personType !== undefined)
    //   that.personType = that.$route.query.personType;
    // if (that.$route.query.invoiceType !== undefined){
    //   that.is_inv = '1';
    //   that.invoiceType = that.$route.query.invoiceType;
    // }else{
    //   // that.invoiceType = '0';
    //   that.is_inv = '0'
    // }
  },
  filters: {
    hide(val) {
      return val && val.substr(0, 3) + "****" + val.substr(7);
    }
  },
  methods: {
    getParameter: function() {
      var self = this;
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      const win = window;
      var obj = {
        action: "getParameter",
        content: {
          method: "setUserInfo",
          Parameter: {}
        }
      };
      if (isAndroid) {
        App.onAppResponse(JSON.stringify(obj));
      }
      if (isIOS) {
        win.webkit.messageHandlers.onAppResponse.postMessage(
          JSON.stringify(obj)
        );
      }
    },
    getElementOffsetTop(el) {
      let top = el.offsetTop;
      let cur = el.offsetParent;
      while (cur != null) {
        top += cur.offsetTop;
        cur = cur.offsetParent;
      }
      return top;
    },

    componentDidMount() {
      const u = navigator.userAgent;
      const isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //android终端
      // alert('android'+isAndroid)
      if (isAndroid && this.from1 != "app") {
        // android统一处理，不影响ios的自身处理
        const body = document.getElementsByTagName("body")[0]; // 兼容获取body
        const regDom = document.querySelector(".order-submission"); // 获取页面根元素
        const content = document.querySelector(".order-submission"); // 表单内容部分

        // const scrollHeight = body.scrollHeight // 网页文档高
        // const scrollTop = body.scrollTop// 卷上去的高

        const clientHeight = body.clientHeight; //可见高
        const fixHeight = clientHeight / 3; // 定位高，弹出键盘时input距浏览器上部的距离，自己定义合适的

        // 符合需弹出键盘的元素query
        const queryStr =
          'input[type="text"], input[type="tel"], input[type="password"], textarea';
        const inputs = content.querySelectorAll(queryStr);

        // console.log(inputs)

        const offsetTopArr = Array.prototype.map.call(inputs, item => {
          return this.getElementOffsetTop(item); // offsetTop只能获取到顶部距它的offsetParent的距离，需此方法获取到元素距顶部的距离
        });

        inputs.forEach((item, i) => {
          item.addEventListener("focus", () => {
            // 改变top上移页面
            regDom.style.top = "-" + (offsetTopArr[i] - fixHeight) + "px";
          });

          item.addEventListener("blur", () => {
            // 恢复top
            regDom.style.top = 0;
          });
        });
      }
    },
    //个人
    changetype() {
      this.showred1 = this.showred2 = this.showred3 = 0;
      this.personType = 1;
      if (this.email != "" && this.reg2.test(this.email)) {
        this.alltrue = 1;
      } else {
        this.alltrue = 0;
      }
      // this.iinvoiceRise = '';
      // this.invoiceNumber = '';
    },
    //企业
    changetype1() {
      this.showred1 = this.showred2 = this.showred3 = 0;
      this.personType = 2;
      let { invoiceRise, invoiceNumber, email } = this;
      if (
        invoiceRise != "" &&
        invoiceNumber != "" &&
        email != "" &&
        this.reg1.test(invoiceRise) &&
        this.checkTaxId(invoiceNumber) &&
        this.reg2.test(email)
      ) {
        this.alltrue = 1;
      } else {
        this.alltrue = 0;
      }
      // this.iinvoiceRise = '';
      // this.invoiceNumber = '';
    },
    //校验发票抬头
    reginvoiceRise() {
      // let reg1 = /^[\u4e00-\u9fa5]{2,20}$/; //发票抬头
      let { personType, invoiceRise, invoiceNumber, email } = this;
      if (personType == 2) {
        if (invoiceRise == "") {
          // this.showred1 = 1;
          this.alltrue = 0;
          return;
          // return this.$dialog.toast({ mes: "请您填写发票对应信息" });
        } else if (!this.reg1.test(invoiceRise)) {
          // this.showred1 = 1;
          // this.invoiceRise = '';
          this.alltrue = 0;
          return;
          // return this.$dialog.toast({ mes: "您的抬头名称有误，请重新填写" });
        }
        if (
          invoiceNumber != "" &&
          email != "" &&
          this.checkTaxId(invoiceNumber) &&
          this.reg2.test(email)
        ) {
          this.alltrue = 1;
        } else {
          this.alltrue = 0;
        }
        // return true;
      }
    },
    //校验发票税号
    reginvoiceNumber() {
      let { personType, invoiceNumber, invoiceRise, email } = this;
      if (personType == 2) {
        if (invoiceNumber == "") {
          // this.showred2 = 1;
          this.alltrue = 0;
          return;
          // return this.$dialog.toast({ mes: "请您填写发票对应信息" });
        } else if (!this.checkTaxId(invoiceNumber)) {
          // this.showred2 = 1;
          // this.invoiceNumber = '';
          this.alltrue = 0;
          return;
          // return this.$dialog.toast({
          //   mes: "您的纳税人识别号有误，请重新填写"
          // });
        }
        if (
          invoiceRise != "" &&
          email != "" &&
          this.reg1.test(invoiceRise) &&
          this.reg2.test(email)
        ) {
          this.alltrue = 1;
        } else {
          this.alltrue = 0;
        }
        // return true;
      }
    },
    //校验邮箱
    regemail() {
      // let reg2 = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; //邮箱
      let { email, personType, invoiceRise, invoiceNumber } = this;
      if (email == "") {
        // this.showred3 = 1;
        this.alltrue = 0;
        return;
        // alert(this.showred3);
        // return this.$dialog.toast({ mes: "请您填写发票对应信息" });
      } else if (!this.reg2.test(email)) {
        // this.showred3 = 1;
        // this.email = '';
        this.alltrue = 0;
        return;
        // return this.$dialog.toast({ mes: "您的电子邮件格式有误，请重新填写" });
      }
      if (personType == 1) {
        this.alltrue = 1;
      } else if (personType == 2) {
        if (
          invoiceRise != "" &&
          invoiceNumber != "" &&
          this.reg1.test(invoiceRise) &&
          this.checkTaxId(invoiceNumber)
        ) {
          this.alltrue = 1;
        } else {
          this.alltrue = 0;
        }
      }

      // return true;
    },

    //显示发票
    showInvoice() {
      if (!this.addressInfo.id && !this.shipping_type)
        return this.$dialog.toast({ mes: "请选择收货地址" });
      this.is_showinv = !this.is_showinv;
      // this.componentDidMount();
    },
    /**
     * javascript验证纳税人识别号格式
     * @param  taxId [纳税人识别号]
     * @return true格式正确，false格式错误
     */
    checkTaxId(taxId) {
      var regArr = [
          /^[\da-z]{10,15}$/i,
          /^\d{6}[\da-z]{10,12}$/i,
          /^[a-z]\d{6}[\da-z]{9,11}$/i,
          /^[a-z]{2}\d{6}[\da-z]{8,10}$/i,
          /^\d{14}[\dx][\da-z]{4,5}$/i,
          /^\d{17}[\dx][\da-z]{1,2}$/i,
          /^[a-z]\d{14}[\dx][\da-z]{3,4}$/i,
          /^[a-z]\d{17}[\dx][\da-z]{0,1}$/i,
          /^[\d]{6}[\da-z]{13,14}$/i
        ],
        j = regArr.length;
      for (var i = 0; i < j; i++) {
        if (regArr[i].test(taxId)) {
          return true;
        }
      }
      //纳税人识别号格式错误
      return false;
    },

    // submit: function() {
    //   let reg1 = /^[\u4e00-\u9fa5]{2,20}$/; //发票抬头
    //   let reg2 = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; //邮箱
    //   this.alltrue = 0;
    //   let { personType } = this;
    //   let { invoiceRise, invoiceNumber, email } = this;
    //   if (personType == 2) {
    //     if (invoiceRise == "") {
    //       this.showred1 = 1;
    //       return this.$dialog.toast({ mes: "请您填写发票对应信息" });
    //     } else if (!reg1.test(invoiceRise)) {
    //       return this.$dialog.toast({ mes: "您的抬头名称有误，请重新填写" });
    //     }
    //     if (invoiceNumber == "") {
    //       this.showred2 = 1;
    //       return this.$dialog.toast({ mes: "请您填写发票对应信息" });
    //     } else if (!this.checkTaxId(invoiceNumber)) {
    //       return this.$dialog.toast({
    //         mes: "您的纳税人识别号有误，请重新填写"
    //       });
    //     }
    //   }

    //   if (email == "") {
    //     this.showred3 = 1;
    //     return this.$dialog.toast({ mes: "请您填写发票对应信息" });
    //   } else if (!reg2.test(email)) {
    //     return this.$dialog.toast({ mes: "您的电子邮件格式有误，请重新填写" });
    //   }
    //   this.alltrue = 1;
    // },

    // 嵌入app获取支付状态
    onWebResponse: function(str) {
      // alert(123);
      var obj = JSON.parse(str);
      var action = obj.action;
      var self = this;
      var content = obj.content;
      // alert(action);
      if (action == "payResult") {
        // alert(content.status);
        // let url = "/order/status/" + data.result.orderId;
        // this.$router.replace({
        //   path: url + "/2"
        // });
        if (content.status == "0") {
          // return this.$dialog.error("支付失败");
          this.$router.push({
            path: "/order/status/" + this.orderId + "/2?isback=1&from1=app"
          });
        } else if (content.status == "1") {
          // return this.$dialog.error("支付成功");
          this.$router.push({
            path: "/order/status/" + this.orderId + "/2?isback=1&from1=app"
          });
        }
      } else if (action == "getKeyboardHeight") {
        console.log(height);
      } else if (action == "setUserInfo") {
        let did = content.did;
        let isToken = content.ds_token;
        let expires_time = content.ds_expires_time;
        let isSalt = content.salt;
        if (isToken == "") {
          this.$store.commit(
            "LOGIN",
            isToken
            // dayjs(expires_time) - newTime
          );
        } else {
          // alert(isToken);
          this.$store.commit(
            "LOGIN",
            isToken
            // dayjs(expires_time) - newTime
          );
        }
      }
    },
    //设置发票
    setInvoice: function() {
      this.$router.push({
        path:
          "/order/invoice/" +
          this.cartid +
          "?name=" +
          this.userInfo.real_name +
          "&mobile=" +
          this.userInfo.phone +
          "&image=" +
          this.orderGroupInfo.cartInfo[0].productInfo.image +
          "&price=" +
          this.orderPrice.total_price
      });
    },
    showAllDiv: function() {
      var that = this;
      let shipping_type = this.shipping_type;
      if (!this.active) return this.$dialog.toast({ mes: "请选择支付方式" });
      if (this.onlyVirtual) {
        if (!this.phoneInfo.phone) {
          return this.$dialog.toast({ mes: "请填写手机号" });
        }
      } else {
        if (!this.addressInfo.id && !this.shipping_type) {
          return this.$dialog.toast({ mes: "请选择收货地址" });
        }
      }
      if (this.shipping_type) {
        if (
          (this.contacts === "" || this.contactsTel === "") &&
          this.shipping_type
        )
          return this.$dialog.toast({ mes: "请填写联系人或联系人电话" });
        if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(this.contactsTel)) {
          return this.$dialog.toast({ mes: "请填写正确的手机号" });
        }
        if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(this.contacts)) {
          return this.$dialog.toast({ mes: "请填写您的真实姓名" });
        }
      }
      let { personType, invoiceRise, invoiceNumber, email } = this;
      let reg1 = /^[\u4e00-\u9fa5]{2,20}$/; //发票抬头
      let reg2 = /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/; //邮箱
      if (this.is_showinv) {
        if (personType == 2) {
          if (invoiceRise == "") {
            this.showred1 = 1;
            // this.alltrue = 0;
            return this.$dialog.toast({ mes: "请您填写发票对应信息" });
          } else if (!reg1.test(invoiceRise)) {
            this.showred1 = 1;
            this.invoiceRise = "";
            // this.alltrue = 0;
            return this.$dialog.toast({ mes: "您的抬头名称有误，请重新填写" });
          }
          if (invoiceNumber == "") {
            this.showred2 = 1;
            // this.alltrue = 0;
            return this.$dialog.toast({ mes: "请您填写发票对应信息" });
          } else if (!this.checkTaxId(invoiceNumber)) {
            this.showred2 = 1;
            this.invoiceNumber = "";
            // this.alltrue = 0;
            return this.$dialog.toast({
              mes: "您的纳税人识别号有误，请重新填写"
            });
          }

          // if(invoiceNumber!=''&&email!=''){
          //   this.alltrue = 1;
          // }else{
          //   this.alltrue = 0;
          // }
          // return true;
        }
        if (email == "") {
          this.showred3 = 1;
          // this.alltrue = 0;
          // alert(this.showred3);
          return this.$dialog.toast({ mes: "请您填写发票对应信息" });
        } else if (!reg2.test(email)) {
          this.showred3 = 1;
          this.email = "";
          // this.alltrue = 0;
          return this.$dialog.toast({
            mes: "您的电子邮件格式有误，请重新填写"
          });
        }
      }

      this.toPayMoney = true;
    },
    hidetoPayMoney: function() {
      this.toPayMoney = false;
    },
    nothing: function() {},
    choiceType: function(type) {
      this.active = type;
      console.log(this.active);
    },
    //跳转到收获地址
    goAddressPages: function() {
      const phone = this.phoneInfo.phone;
      const path = this.onlyVirtual
        ? `/user/add_phone?phone=${phone ? phone : ""}`
        : "/user/add_manage";
      this.$router.push(path);
      this.$emit("redirect");
    },
    // 获取门店列表数据
    getList: function() {
      let data = {
        latitude: cookie.get(LATITUDE) || "", //纬度
        longitude: cookie.get(LONGITUDE) || "", //经度
        page: 1,
        limit: 10
      };
      storeListApi(data)
        .then(res => {
          this.storeList = res.data.list[0];
        })
        .catch(err => {
          this.$dialog.error(err.msg);
        });
    },
    // 跳转到门店列表
    showStoreList() {
      this.$store.commit("GET_TO", "orders");
      this.$router.push("/shop/storeList/orders");
    },
    getUserInfo() {
      getUser()
        .then(res => {
          this.userInfo = res.data;
        })
        .catch(() => {});
    },
    addressType: function(index) {
      if (index && !this.system_store.id)
        return this.$dialog.error("暂无门店信息，您无法选择到店自提！");
      this.shipping_type = index;
    },
    computedPrice() {
      let shipping_type = this.shipping_type;
      postOrderComputed(this.orderGroupInfo.orderKey, {
        addressId: this.addressInfo.id,
        useIntegral: this.useIntegral ? 1 : 0,
        couponId: this.usableCoupon.id || 0,
        shipping_type: parseInt(shipping_type) + 1,
        payType: this.active,
        type: 0
      })
        .then(res => {
          const data = res.data;
          if (data.status === "EXTEND_ORDER") {
            var mer_id = "";
            if (that.$route.query.mer_id.indexOf("3D") > -1) {
              mer_id = that.$route.query.mer_id.split("3D")[1];
            } else {
              mer_id = that.$route.query.mer_id;
            }
            this.$router.replace({
              path: "/order/detail/" + data.result.orderId + "?mer_id=" + mer_id
            });
          } else {
            this.orderPrice = data.result;
            this.firstprice = this.orderPrice.orderTotalPrice.split(".")[0];
            this.secondprice = this.orderPrice.orderTotalPrice.split(".")[1];
          }
        })
        .catch(res => {
          this.$dialog.error(res.msg);
        });
    },
    getCartInfo() {
      let that = this;
      const cartIdArr = this.$route.params.id.split(",");
      if (!cartIdArr) {
        this.$dialog.error("参数有误");
        return this.$router.go(-1);
      }
      // if (that.$route.query.invoiceRise !== undefined)
      //   that.invoiceRise = that.$route.query.invoiceRise;

      // if (that.$route.query.invoiceNumber !== undefined)
      //   that.invoiceNumber = that.$route.query.invoiceNumber;
      // if (that.$route.query.email !== undefined)
      //   that.email = that.$route.query.email;
      // if (that.$route.query.personType !== undefined)
      //   that.personType = that.$route.query.personType;
      // if (that.$route.query.invoiceType !== undefined)
      //   that.invoiceType = that.$route.query.invoiceType;
      // else{
      //   that.invoiceType = '0';
      // }
      // alert(that.invoiceType);
      let params = {
        cartIdArr,
        type: 0,
        addressId: cookie.get("address_id") || undefined
      };
      postOrderConfirm(params)
        .then(res => {
          this.offlinePayStatus = res.data.offline_pay_status;
          this.orderGroupInfo = res.data;
          for (var i = 0; i < this.orderGroupInfo.cartInfo.length; i++) {
            this.orderNum += this.orderGroupInfo.cartInfo[i].cart_num;
          }
          this.onlyVirtual = this.orderGroupInfo.cartInfo.every(
            item => item.is_virtual == 1
          );
          this.phoneInfo = res.data.virtual_list || {};
          console.log(this.orderNum);
          this.deduction = res.data.deduction;
          // this.usableCoupon = res.data.usableCoupon || {};
          this.addressInfo = res.data.addressInfo || {};
          this.system_store = res.data.system_store || {};
          this.store_self_mention = res.data.store_self_mention;
          this.computedPrice();
        })
        .catch(res => {
          this.$dialog.error(res.msg);
          this.$router.go(-1);
        });
    },
    addressTap: function() {
      this.showAddress = true;
      if (!this.addressLoaded) {
        this.addressLoaded = true;
        this.$refs.mychild.getAddressList();
      }
    },
    addressRedirect() {
      this.addressLoaded = false;
      this.showAddress = false;
    },
    couponTap: function() {
      this.showCoupon = true;
    },
    changeCoupon: function(coupon) {
      if (!coupon) {
        this.usableCoupon = { coupon_price: "不使用优惠券", id: 0 };
      } else {
        this.usableCoupon = coupon;
      }
      this.computedPrice();
      // this.getCartInfo()
    },
    payItem: function(index) {
      this.active = index;
      this.computedPrice();
    },
    changeAddress(addressInfo) {
      this.addressInfo = addressInfo;
      this.computedPrice();
    },
    //ios微信支付做桥
    payTypes: function(data) {
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      const win = window;
      var obj = {
        action: "payBridge", //方法名
        content: {
          type: this.active, //微信 aliPay//支付宝
          data: data //支付信息
        }
      };
      if (isAndroid) {
        App.onAppResponse(JSON.stringify(obj));
      }
      if (isIOS) {
        win.webkit.messageHandlers.onAppResponse.postMessage(
          JSON.stringify(obj)
        );
      }
    },
    payTypeWxapp: function(data) {
      console.log(data);
      wx.miniProgram.navigateTo({
        url:
          "/pages/pay/pay?prepay_id=" +
          data.jsConfig.prepay_id +
          "&appid=" +
          data.jsConfig.appid +
          "&nonce_str=" +
          data.jsConfig.nonce_str +
          "&sign=" +
          data.jsConfig.sign +
          "&sign_type=" +
          data.jsConfig.sign_type +
          "&timeStamp=" +
          data.jsConfig.timeStamp +
          "&orderId=" +
          data.orderId
      });
    },
    createOrder() {
      var that = this;
      let shipping_type = this.shipping_type;
      if (!this.active) return this.$dialog.toast({ mes: "请选择支付方式" });
      if (this.onlyVirtual) {
        if (!this.phoneInfo.phone) {
          return this.$dialog.toast({ mes: "请填写手机号" });
        }
      } else {
        if (!this.addressInfo.id && !this.shipping_type) {
          return this.$dialog.toast({ mes: "请选择收货地址" });
        }
      }
      if (this.shipping_type) {
        if (
          (this.contacts === "" || this.contactsTel === "") &&
          this.shipping_type
        )
          return this.$dialog.toast({ mes: "请填写联系人或联系人电话" });
        if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(this.contactsTel)) {
          return this.$dialog.toast({ mes: "请填写正确的手机号" });
        }
        if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(this.contacts)) {
          return this.$dialog.toast({ mes: "请填写您的真实姓名" });
        }
      }
      if (this.active == "weChatPay") {
        if (this.from1 == "app" || this.from1.indexOf("3Dapp") != "-1") {
          this.from = "weChatPayApp";
        } else if (
          this.from1 == "wxapp" ||
          this.from1.indexOf("wxapp") != "-1"
        ) {
          this.from = "weChatPaywxApp";
        } else {
        }
      }
      if (this.active == "aliPay") {
        if (this.from1 == "app" || this.from1.indexOf("3Dapp") != "-1") {
          this.from = "aliPayApp";
        } else {
          this.from = "aliPayH5";
        }
      }
      var dataJson = "";
      var u = navigator.userAgent;
      // app = navigator.appVersion;
      // var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      if (isIOS) {
        dataJson = "ios";
      } else {
        dataJson = "qwe";
      }
      this.$dialog.loading.open("生成订单中");
      var mer_id = "";
      if (that.$route.query.mer_id.indexOf("3D") > -1) {
        mer_id = that.$route.query.mer_id.split("3D")[1];
      } else {
        mer_id = that.$route.query.mer_id;
      }
      createOrder(this.orderGroupInfo.orderKey, {
        real_name: this.addressInfo.real_name,
        phone: this.onlyVirtual ? this.phoneInfo.phone : this.addressInfo.phone,
        addressId: this.onlyVirtual ? 0 : this.addressInfo.id,
        useIntegral: this.useIntegral ? 1 : 0,
        couponId: this.usableCoupon.id || 0,
        payType: this.active,
        pinkId: this.pinkId,
        seckill_id: this.orderGroupInfo.seckill_id,
        combinationId: this.orderGroupInfo.combination_id,
        bargainId: this.orderGroupInfo.bargain_id,
        from: this.from,
        mark: this.mark || "",
        shipping_type: parseInt(shipping_type) + 1,
        store_id: this.storeItem ? this.storeItem.id : 0,
        isIospay: dataJson,
        // is_inv:that.is_inv,
        is_inv: this.alltrue == 1 ? "1" : "0",
        is_con: that.invoiceType,
        invType: "1",
        upType: that.personType,
        up: that.invoiceRise,
        tax: that.invoiceNumber,
        email: that.email,
        mer_id: mer_id,
        oId: cookie.get("OID")
      })
        .then(res => {
          this.toPayMoney = false;
          this.$dialog.loading.close();
          this.orderId = res.data.result.orderId;
          const data = res.data;
          console.log(data.result.jsConfig);
          let url = "/order/status/" + data.result.orderId;
          switch (data.status) {
            case "ORDER_EXIST":
            case "EXTEND_ORDER":
            case "PAY_DEFICIENCY":
            case "PAY_ERROR":
              this.$dialog.toast({ mes: res.msg });
              this.$router.replace({
                path: url + "/0?msg=" + res.msg
              });
              break;
            case "SUCCESS":
              this.$dialog.success(res.msg);
              this.$router.replace({
                path: url + "/1"
              });
              break;
            case "WECHAT_H5_PAY":
              setTimeout(() => {
                location.href = data.result.jsConfig.mweb_url;
              }, 1);
              break;
            case "WECHAT_PAY":
              WeixinJSBridge.invoke(
                "getBrandWCPayRequest",
                {
                  appId: data.result.jsConfig.appId,
                  nonceStr: data.result.jsConfig.nonceStr,
                  package: data.result.jsConfig.package,
                  signType: data.result.jsConfig.signType,
                  timeStamp: data.result.jsConfig.timestamp,
                  paySign: data.result.jsConfig.paySign
                },
                function(res) {
                  console.log(res);
                  WeixinJSBridge.log(res.err_msg + "err");
                  if (res.err_msg == undefined) {
                    that.$router.replace({
                      path: url + "/4"
                    });
                  }
                  if (res.err_msg == "get_brand_wcpay_request:ok") {
                    that.$router.replace({
                      path: url + "/4"
                    });
                  } else if (res.err_msg == "get_brand_wcpay_request:cancel") {
                    that.$router.replace({
                      path: url + "/4"
                    });
                  } else {
                    that.$router.replace({
                      path: url + "/4"
                    });
                  }
                }
              );
              break;
            case "WECHAT_APP_PAY":
              this.payTypes(data.result);
              break;
            case "WECHAT_WXAPP_PAY":
              this.payTypeWxapp(data.result);
              break;
            case "ALI_APP_PAY":
              this.payTypes(data.result);
              break;
            case "ALI_H5_PAY":
              setTimeout(() => {
                location.href = data.result.jsConfig;
              }, 1);
              break;
          }
        })
        .catch(err => {
          this.$dialog.loading.close();
          this.$dialog.error(err.msg || "创建订单失败");
          this.$dialog.loading.close();
          this.$router.go(-1);
        });
    }
  }
};
</script>
